"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.noticeRouter = void 0;
const express_1 = __importDefault(require("express"));
const log4js_1 = require("log4js");
const NoticeEntity_1 = require("../entity/NoticeEntity");
const logger = (0, log4js_1.getLogger)('route/notice');
function noticeRouter(app) {
    const router = express_1.default.Router();
    router.get('/list', async ({ query }, res) => {
        const { userId, limit = 10, page = 1 } = query;
        logger.debug('notice/list: => ', query);
        const data = await NoticeEntity_1.NoticeEntity.createQueryBuilder('notice')
            .where("notice.receiverId=:userId", { userId })
            .addOrderBy("releaseTime", "DESC")
            .limit(limit)
            .offset(limit * (page - 1))
            .getMany();
        logger.debug('notice/list: => ', data);
        res.status(200).send({ result: 'OK', data });
    });
    return router;
}
exports.noticeRouter = noticeRouter;
